/* 
** 车险订单 获取附件列表,补全初始路径
** 将附件列表重构为，组件所需结构
*/
import carUploadMods from '@/components/ivew_conf/car_upload_mods'
import {deepCopy} from '@/utils/tools'

export default (ctx, next) =>{
    
    let resData = ctx.params;
    let modsStr = JSON.stringify(resData);
    let template = deepCopy(carUploadMods);

    //如果无上传，将返回null，需要自定义配置初始模板
    if(!resData){
        resData = [];
    }

    // 寻找对应模板，并赋值
    template.forEach((mod, index) =>{

        (<string>mod.title).replace('"', '');

        let not = modsStr.search(mod.title) === -1;
        
        if(not){
            resData.splice(index, 0, mod)
        }

    })
    
    ctx.params = resData;

    next()
}